package io.bdmc.modules.sys.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.bdmc.common.annotation.SysLogger1;
import io.bdmc.common.utils.R;
import io.bdmc.common.utils.Constant.ModifyName;
import io.bdmc.modules.sys.entity.SysConfig;
import io.bdmc.modules.sys.service.ISysConfigService;

/**
 * <p>
 * 系统配置信息表 前端控制器
 * </p>
 *
 * @author ping
 * @since 2020-06-24
 */

// "SysConfig", description = "系统配置信息表")
@RestController
@RequestMapping("/bss/sysConfig")
public class SysConfigController extends AbstractController {

	@Autowired
	ISysConfigService _sysconfigSvs;

	@RequestMapping("/list")
	// "分页查询SysConfig", notes = "分页查询系统配置信息表")
	@RequiresPermissions("bss:sysConfig:list")
	public R list() {

		List<SysConfig> configs = _sysconfigSvs.list();
		return R.ok().putData(configs);
	}

	@SysLogger1(value = "新增系统配置信息表", entityType = SysConfig.class, operationType = ModifyName.ADD)
	@RequestMapping("/save")
	// "新增SysConfig", notes = "新增系统配置信息表")
	@RequiresPermissions("bss:sysConfig:save")
	public R save(@RequestBody SysConfig sysconfig) {

		Boolean b = sysconfig.insert();
		return R.trueOrFalse(b);
	}

	@SysLogger1(value = "修改系统配置信息表", entityType = SysConfig.class, operationType = ModifyName.UPDATE)
	@RequestMapping("/update")
	// "修改SysConfig", notes = "修改系统配置信息表")
	@RequiresPermissions("bss:sysConfig:update")
	public R update(@RequestBody SysConfig sysconfig) {
		Boolean b = sysconfig.updateById();
		return R.trueOrFalse(b);
	}
}
